package com.woniuxy.admin.service.impl;

import com.woniuxy.admin.entity.Resource;
import com.woniuxy.admin.mapper.ResourceMapper;
import com.woniuxy.admin.service.ResourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.admin.service.ResourseRoleService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ...
 * @since 2024年05月22日
 */
@Service
public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> implements ResourceService {

    @javax.annotation.Resource
    private ResourseRoleService resourseRoleService;
    @Override
    public List<String> findResourceByRoleId(Integer roleId) {
     List<Integer>resourceIds=resourseRoleService.selectResourseIdByRoleId(roleId);
        if(resourceIds==null) return null;
        List<Resource> resources = this.listByIds(resourceIds);
        List<String> collect = resources.stream().map(r -> r.getResoursePath()).collect(Collectors.toList());
        return collect;
    }
}
